var express = require('express');
var path = require('path');

var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var index = require('./routes/index');
var admin = require('./routes/admin');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.use(cookieParser());
app.use("/public",express.static("public"));
app.use("/admin/article/public",express.static("public"));
app.use("/admin/product/public",express.static("public"));

app.use(express.static(path.join(__dirname, 'public')));

var Host = "";

app.use(function (req, res, next) {
  Host = "http://" + req.headers.host;
  next();
})

app.use('/', index);
app.use('/admin', admin);
app.use(function(req,res){
     res.render("default/404", {
    host: Host
  })
})

app.listen(2000,'127.0.0.1')


